package com.longcai.config.rabbitmq;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;

/**
 * 消息发送到交换机确认机制
 *
 * @author zhaojie
 * @date 2019/04/20 15:53
 */
public class MsgSendConfirmCallBack implements RabbitTemplate.ConfirmCallback {

    private static final Logger logger = LoggerFactory.getLogger(MsgSendConfirmCallBack.class);

    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        if (ack) {
            System.out.println("订单确认成功" + correlationData.getId() + " " + cause);
        } else {
            logger.error("消息消费失败:" + correlationData.getId() + cause + "重新发送");
        }
    }
}